package com.working.libbase.base

import android.app.Activity
import android.app.Dialog
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.view.WindowManager

abstract class BaseDialog(context: Context) : Dialog(context) {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

    }

    override fun show() {
        if ((context is Activity) && (context as Activity).isFinishing) {
            return
        }
        super.show()
        window?.let {
            it.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
            val lp = it.attributes
            lp.height = WindowManager.LayoutParams.WRAP_CONTENT
            lp.width = (it.windowManager.defaultDisplay.width * 0.85).toInt()
            it.attributes = lp
        }
    }

}